package leader.action;

import java.util.Date;
import java.util.List;

import leader.bean.MidTable;
import leader.service.DirectTeacherService;
import leader.service.MidteaexpService;

import teacher.bean.Midteaexp;
import teacher.bean.Teacher;
import tools.StringDate;

public class DirectMidteaexpAction {
	private List<MidTable> midtable;
	private Teacher teacher;
	private int[] experid;
	private Date birth;
	private String[] medatetime;
	private String flag;
	public Date getBirth() {
		return birth;
	}
	public void setBirth(Date birth) {
		this.birth = birth;
	}
	
	public Teacher getTeacher() {
		return teacher;
	}
	public void setTeacher(Teacher teacher) {
		this.teacher = teacher;
	}
	public List<MidTable> getMidtable() {
		return midtable;
	}
	public void setMidtable(List<MidTable> midtable) {
		this.midtable = midtable;
	}
	public int[] getExperid() {
		return experid;
	}
	public void setExperid(int[] experid) {
		this.experid = experid;
	}
	public String[] getMedatetime() {
		return medatetime;
	}
	public void setMedatetime(String[] medatetime) {
		this.medatetime = medatetime;
	}
	public String getFlag() {
		return flag;
	}
	public void setFlag(String flag) {
		this.flag = flag;
	}
	public String execute() {
		System.out.println("===================修改教师基本信息==================");
		DirectTeacherService TS = new DirectTeacherService();
		StringDate date = new StringDate();
//		teacher.setTeaId(TS.SelectTeaIdByUser(teacher.getUser()));
		teacher.setInSubDate(date.StringToDate(date.DateToString(teacher.getInSubDate())));
		MidteaexpService midtable = new  MidteaexpService();
		if(midtable.getCountOfMidTable(teacher)>0) {
			midtable.delMidTableByTeaId(teacher);
		}
		if(null != experid) {
			for(int i = 0 ; i < experid.length;i++) {
				midtable.insertMidteaexp(Integer.parseInt(teacher.getTeaId().toString()),experid[i],date.StringToDate(medatetime[experid[i]-1]));
			}
		}		
		teacher.setBirthday(date.StringToDate(date.DateToString(birth)));
		TS.updateTeacherInfo(teacher, teacher);
		System.out.println("==================修改结束======================");
		flag = "success";
		return "success";
	}
}
